package com.vtest.quartz.task.needlecard;

import com.vtest.quartz.domain.needle.ANENeedleEntity;
import com.vtest.quartz.domain.needle.BIDNeedleEntity;
import com.vtest.quartz.service.needle.NeedleService;
import com.vtest.quartz.utils.MailHelper;
import com.vtest.quartz.utils.excel.ExcelUtil;
import com.vtest.quartz.utils.others.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;

/**
 * @program: Quartz
 * @author: tiger
 * @create: 2025-02-14 10:51
 * @Description :
 */

@Slf4j
@Component("ANEReport")
public class ANEReport {

    @Autowired
    private NeedleService needleService;

    public void sendNeedleReport() {
        log.debug("[ANE 针卡报表] 任务开始执行");

        List<ANENeedleEntity> aneNeedleInfoList = needleService.findANENeedleInfo();

        ExcelUtil<ANENeedleEntity> util = new ExcelUtil<>(ANENeedleEntity.class);

        util.exportExcel(aneNeedleInfoList, "ANE_Probe_Card.xlsx"  , StringUtils.EMPTY, true);

        File localFile = new File(util.downFile);
        if (localFile.exists()) {
            MailHelper helper = new MailHelper();
            helper.sendMail("huaiju.zhao@v-test.com.cn"
                    , "ruhu.wang@v-test.com.cn", "ANE 针卡报表", "ANE 针卡报表", util.downFile);
        }

    }
}
